# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
===========================
@Time : 2022/8/21 0021 7:58
@Author : 测试开发工程师
@File : 8. flaskrestx_demo.py
@Software: PyCharm
============================
"""

from flask import Flask
from flask_restx import Resource, Api

# RESTFUL 风格规范的接口
app = Flask(__name__)
api = Api(app)


# 接口路径定义到类上，对应的不同请求操作创建不同的方法
@api.route('/user')
class User(Resource):
    #  RESTFUL 风格的 get 方法
    @app.route('testcase', methods=['get'])
    def get(self):
        return {'code': 0, 'msg': 'get success'}

    #  RESTFUL 风格的 post 方法
    @app.route('testcase', methods=['post'])
    def post_case(self):
        return {'code': 0, 'msg': 'post success'}

    #  RESTFUL 风格的 put 方法
    @app.route('testcase', methods=['put'])
    def post_case(self):
        return {'code': 0, 'msg': 'put success'}

    #  RESTFUL 风格的 delete 方法
    @app.route('testcase', methods=['delete'])
    def post_case(self):
        return {'code': 0, 'msg': 'delete success'}


if __name__ == '__main__':
    app.run(debug=True)
